﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace 聚欣订单分析
{
    public partial class SelectCondition : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                DataBindToGridview();
            }
        }

        private void DataBindToGridview()
        {

            string strLieName = "";
            switch (Request.QueryString["LieName"].ToString())
            {
                case "province":
                    strLieName = "省";
                    break;
                case "city":
                    strLieName = "地市";
                    break;
                case "yys":
                    strLieName = "运营商";
                    break;
                case "type":
                    strLieName = "类型";
                    break;
            }
            string strSQL = "";
            if (strLieName != "地市")
            {
                strSQL = "select distinct " + strLieName + " as SelectContent from tbl_DDB where " + strLieName + " like '%" + this.TextBox1.Text + "%' and " + strLieName + " <>''";
            }
            else
            {
                strSQL = "select distinct " + strLieName + " as SelectContent from tbl_DDB where " + strLieName + " like '%" + this.TextBox1.Text + "%' and 省='" + Request.QueryString["province"].ToString() + "' and " + strLieName + " <>''";
            }

            try
            {
                SqlDataSource1.SelectCommand = strSQL;
                GridView1.DataSourceID = "SqlDataSource1";
                GridView1.DataBind();
            }
            catch (Exception)
            {
                throw new Exception(strSQL + "-" + Request.QueryString["LieName"].ToString());
            }

        }

        protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            this.GridView1.PageIndex = e.NewPageIndex;
            DataBindToGridview();
        }
        protected void iButton4_Click(object sender, EventArgs e)
        {
            DataBindToGridview();
        }
    }
}
